package com.frxuexi.park2212.merchant

import android.graphics.Color
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.MerchantBeanItem
import com.frxuexi.park2212.R
import com.frxuexi.park2212.databinding.ItemMerchantBinding

class MerchantAdapter:BaseQuickAdapter<MerchantBeanItem,BaseViewHolder>(R.layout.item_merchant) {
    lateinit var binding:ItemMerchantBinding

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemMerchantBinding>(viewHolder.itemView)
    }
    override fun convert(helper: BaseViewHolder, item: MerchantBeanItem) {
        binding=DataBindingUtil.getBinding<ItemMerchantBinding>(helper.itemView)!!
        binding.bean=item
        binding.merchantStatus.apply {
            if(item.status=="新建"){
                setBackgroundResource(R.drawable.shape_zhanyong)
                setTextColor(context.resources.getColor(R.color.blue))
            }else if(item.status=="驳回"){
                setBackgroundResource(R.drawable.shape_weihu)
                setTextColor(context.resources.getColor(R.color.orange))
            }else{
                setBackgroundResource(R.drawable.shape_status)
                setTextColor(context.resources.getColor(R.color.green))
            }
        }

    }
}